package xyz.chaobei.feature.utils;

import java.util.Objects;
import java.util.function.Predicate;

/**
 * @copyright (C), 2015-2020
 * @fileName: PredicateTest
 * @author: MRC
 * @date: 2021/2/3 22:38
 * @description:
 */
public class PredicateTest {

    public static void main(String[] args) {

        // 断言字符串长度大于0
        Predicate<String> stringEmpty = (str) -> str.length() > 0;
        Predicate<String> startHello = (str) -> str.startsWith("hello");

        System.out.println("test 空字符=" + stringEmpty.test(""));
        System.out.println("test hello=" + stringEmpty.test("hello"));

        // and 合并两个检验接口，同时满足即可 or 只要有一个满足即可
        System.out.println("test and hello world=" + stringEmpty.and(startHello).test("hello world"));
        System.out.println("test or world=" + stringEmpty.or(startHello).test("world"));
    }

}
